import { fromJS } from 'immutable'
import { constants } from './index'

const defaultStore = fromJS({
  title: '',
  content: '',
})

const reduceHandler = (store = defaultStore, action) => {
  switch (action.type) {
    case constants.CHANGE_DETAIL:
      return store.merge({
        title: fromJS(action.title),
        content: fromJS(action.content),
      })
    default:
      return store
  }
}

export default reduceHandler
